#include "SoundParser.h"
#include "..\utils\Log.h"
#include "..\utils\PlainTextReader.h"
#include "..\base\Engine.h"
#include "..\game\World.h"
#include "..\content\Texture.h"

namespace ds {

bool SoundParser::isSupported(const std::string& fileEnding) const {
	bool ret = false;
	if ( fileEnding == ".wav" ) {
		ret = true;
	}
	return ret;
}

ResourceDeclaration* SoundParser::loadTextFile(const ResourceFile& resourceFile) {
	SoundDecl* td = new SoundDecl(resourceFile.fqName);
	return td;
}

void SoundParser::createResource(ResourceDeclaration* declaration) {
	SoundDecl* td = static_cast<SoundDecl*>(declaration);
	LOGC(logINFO,"SoundParser") << "loading sound" << td->getName();
	std::string filename(td->getName());
	size_t pos = filename.find_last_of("\\");
	std::string soundName = filename.substr(pos+1);
	pos = soundName.find(".");
	soundName = soundName.substr(0,pos);
	soundName[0] = toupper(soundName[0]);
	LOGC(logINFO,"SoundParser") << "sound name: " << soundName;
	gEngine->getResourceManager().loadSound(soundName.c_str(),td->getName().c_str());
}

}
